//
//  WH_DetailDuobaoView.m
//  App_6.23
//
//  Created by wanghao on 16/8/12.
//  Copyright © 2016年 wanghao. All rights reserved.
//

#import "WH_DetailDuobaoView.h"

@interface WH_DetailDuobaoView ()


@end
@implementation WH_DetailDuobaoView

- (IBAction)disBtn:(UIButton *)sender {
    
    [self.delegate dismissBack:_countTF];
}

- (IBAction)dismissBtn:(UIButton *)sender {
    
    [self.delegate dismissBack:_countTF];
}

- (IBAction)fiveBtn:(UIButton *)sender {
    self.countTF.text = @"5";
    self.moneyL.text = [NSString stringWithFormat:@"%@$",self.countTF.text];
    
}
- (IBAction)twoBtn:(UIButton *)sender {
    self.countTF.text = @"20";
    self.moneyL.text = [NSString stringWithFormat:@"%@$",self.countTF.text];
}
- (IBAction)fiftyBtn:(UIButton *)sender {
    self.countTF.text = @"50";
    self.moneyL.text = [NSString stringWithFormat:@"%@$",self.countTF.text];
}
- (IBAction)OneHBtn:(UIButton *)sender {
    self.countTF.text = @"100";
    self.moneyL.text = [NSString stringWithFormat:@"%@$",self.countTF.text];
}

- (IBAction)buyBtn:(UIButton *)sender {
    
    NSString *body =[NSString stringWithFormat:@"action=cart_add&user_id=%@&product_period=%@&product_num=%@", NSUSERID,self.periodStr, self.countTF.text];
    
    [WH_AppTools postUrl:URLstr body:body result:HXJSON requestStyle:HXRequestString headerFile:nil success:^(id result) {
        NSDictionary *dic = result;
        NSString *status = [dic objectForKey:@"status"];
        NSString *message = [dic objectForKey:@"message"];
        if ([status isEqualToString:@"success"]) {
            
            
            [self.delegate dismissBack:_countTF];
            //线程延迟
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                NSLog(@"打水吧");
                [self.delegate pushTocart:_countTF];

            });
        }else{
            
            [WSProgressHUD showImage:nil status:message];
            
        }
        
    } failure:^(NSError *error) {
        
        
    }];
    

}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
